package com.zyz.C_数组.练习;

/**
 * @author: vick
 * @Date: 2025/3/13
 * @Description:
 * @version: 1.0
 */
public class Demo5 {
    public static void main(String[] args) {
        int[] nums = {1, 3, 5, 7, 9};
        int target = 5;
        boolean found = false;

        /*for (int i = 0; i < nums.length; i++) {
            if (nums[i] == target) {
                found = true;
                break;
            }
        }*/
        for (int num : nums) {
            if (num == target) {
                found = true;
                break;
            }
        }

        if (found) {
            System.out.println("找到了");
        }else {
            System.out.println("不在数组中");
        }
    }
}
